require("../../../utils/function.js");

var e = getApp(), t = require("../../../api.js");

Page({
    data: {
        handheld:"",
        pageType: null,
        fontImage: null,
        backImage: null,
        idCardPhoto: null,
        idCardPhotoTest: !1,
        driverPhoto: null,
        driverPhotoTest: !1,
        positive: "",
        reverse: "",
        idreverse: "",
        idpositive: "",
        drivers: "",
        isChange: !1
    },
    upFontloadFile: function(a) {
        console.log(a.currentTarget.dataset.type);
        console.log(!this.data.isChange);
        if (!this.data.isChange) {
            a.currentTarget.dataset.type
            var i = this;
            wx.showLoading(), wx.chooseImage({
                success: function(a) {
                    console.log(a);
                    var s = a.tempFilePaths;
                    wx.uploadFile({
                        url: t.driver.uploadcar,
                        filePath: s[0],
                        name: "file",
                        formData: {
                            access_token: wx.getStorageSync("access_token"),
                            _uniacid: e.siteInfo.uniacid,
                            _acid: e.siteInfo.acid
                        },
                        success: function(e) {
                            console.log(e);
                            wx.hideLoading();
                            var t = JSON.parse(e.data);
                            0 != t.code ? 1 == t.code && (i.setData({
                                handheld: t.data
                            }), wx.setStorageSync("handheld", t.data)) : wx.showToast({
                                title: t.msg,
                                icon: "none"
                            });
                        }
                    });
                }
            });
        }
    },
    // upBackloadFile: function(a) {
    //     if (!this.data.isChange) {
    //         var i = this;
    //         a.currentTarget.dataset.type;
    //         wx.chooseImage({
    //             success: function(a) {
    //                 var s = a.tempFilePaths;
    //                 wx.showLoading(), wx.uploadFile({
    //                     url: t.driver.uploadcar,
    //                     filePath: s[0],
    //                     name: "file",
    //                     formData: {
    //                         user: "test",
    //                         access_token: wx.getStorageSync("access_token"),
    //                         _uniacid: e.siteInfo.uniacid,
    //                         _acid: e.siteInfo.acid
    //                     },
    //                     success: function(e) {
    //                         if (wx.hideLoading(), 200 == e.statusCode) {
    //                             var t = JSON.parse(e.data);
    //                             if (0 == t.code) return void wx.showToast({
    //                                 title: t.msg,
    //                                 icon: "none"
    //                             });
    //                             1 == t.code && (i.setData({
    //                                 idreverse: t.data
    //                             }), wx.setStorageSync("idreverse", t.data));
    //                         }
    //                     }
    //                 });
    //             }
    //         });
    //     }
    // },
    intoPageHandler: function(e) {
        this.data.handheld && (wx.setStorageSync("handheld", this.data.handheld), 
        wx.showToast({
            title: "上传成功",
            success: function() {
                setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1500);
            }
        }));
    },
    onLoad: function(t) {
        t.uid && e.shareCouponsMessage(t.uid), "true" == t.isChange && this.setData({
            isChange: !0
        }), "driverPhoto" == t.type && "" != wx.getStorageSync("driving_license") && this.setData({
            positive: wx.getStorageSync("driving_license").driverfPhoto,
            reverse: wx.getStorageSync("driving_license").driverPhoto
        }), "handheld" == t.type && ("" != wx.getStorageSync("handheld") && this.setData({
            // positive: wx.getStorageSync("id_card_pic").id_card_pic,
            handheld: wx.getStorageSync("handheld")
        }), console.log("正面正面", this.data.reverse), console.log("正面正面22", this.data.pageType)), 
        this.setData({
            pageType: t.type
        });
    },
    onShow: function() {
        var e = wx.getStorageSync("handheld") || ""
        console.log(e, "------"), this.setData({
            driver: wx.getStorageSync("driver_information"),
          
            handheld: e
        });
    },
    onShareAppMessage: function() {
        var t = e.shareAppMessage().title, a = e.shareAppMessage().imageUrl, i = e.shareAppMessage().desc, s = e.shareAppMessage().path;
        return console.log(e.shareAppMessage()), {
            title: t,
            imageUrl: a,
            desc: i,
            path: s
        };
    }
});